//package com.woniuxy.commons.consumer;
//
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.woniuxy.elderlycare.dao.MemberMapper;
//import com.woniuxy.elderlycare.model.Member;
//import com.woniuxy.elderlycare.param.member.MemberOpenParam;
//import com.woniuxy.elderlycare.util.StateUtil;
//import org.springframework.amqp.rabbit.annotation.RabbitHandler;
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
//import java.time.LocalDateTime;
//
//@Component
//@RabbitListener(queues = "member_open_queue")
//public class MemberOpenConsumer {
//    @Autowired
//    private MemberMapper memberMapper;
//    @RabbitHandler
//    public void handler(MemberOpenParam param){
//        QueryWrapper<Member> wrapper = new QueryWrapper<>();
//        wrapper.eq("user_id",param.getUserId());
//        Member member = memberMapper.selectOne(wrapper);
//        if (member.getMemberState()!= StateUtil.MEMBER_OPEN){
//            member.setMemberState(StateUtil.MEMBER_OPEN);
//            member.setMemberOpenTime(LocalDateTime.now());
//            member.setMembershipExpirationTime(LocalDateTime.now().plusMonths(param.getTime()));
//        }else {
//            member.setMembershipExpirationTime(member.getMembershipExpirationTime().plusMonths(param.getTime()));
//        }
//        memberMapper.updateById(member);
//    }
//}
